<template>
  <div>
    <a-card :title="title">
      <a-card-grid style="width: 30%;height: 80px; text-align: center" :hoverable="false" >序号</a-card-grid>
      <a-card-grid style="width: 30%;height: 80px;text-align: center" :hoverable="false">基数</a-card-grid>
      <a-card-grid style="width: 40%;height: 80px; text-align: center" :hoverable="false" >固定比例</a-card-grid>
      <a-card-grid style="width: 30%;height: 80px; text-align: center" :hoverable="false" >1</a-card-grid>
      <a-card-grid style="width: 30%;height: 80px;text-align: center" :hoverable="false">{{ base }}</a-card-grid>
      <a-card-grid style="width: 40%;height: 80px; text-align: center" :hoverable="false" >
        <div>
          <div v-show="edit" style="left: -10px; width: 80%; top: -23px;text-align: left;" >
            <a-input-number
              :min="0"
              :max="100"
              :precision="2"
              v-model="currentRate"
              placeholder="请输入固定比率(%)"/>
          </div>
          <span v-show="!edit">{{ showRate(rate ? (rate * 100).toFixed(2) : undefined) }}</span>
        </div>
      </a-card-grid>
    </a-card>
  </div>
</template>
<script>
import { showRate } from './config'

export default {
  name: 'StaticCard',
  components: {
  },
  props: {
    title: {
      type: String,
      default: () => ''
    },
    rate: {
      type: [Number, String],
      default: () => {}
    },
    edit: {
      type: Boolean,
      default: () => false
    },
    base: {
      type: String,
      default: '合同额'
    }
  },
  watch: {
    edit: function (edit) {
      if (edit) {
        this.currentRate = this.rate ? (this.rate * 100).toFixed(2) : undefined
      }
    }
  },
  data () {
    this.showRate = showRate
    return {
      currentRate: 0
    }
  },
  methods: {
    getValue () {
      /**
       * rate 固定提成比率
       */
      return {
        rate: this.currentRate / 100
      }
    }
  }
}
</script>
